class BeanFactory {

    private _beanMap: {};

    constructor() {
        this._beanMap = {};
    }

    /**
     * 设置可带参数的bean
     * @param cls 
     * @param args 
     */
    getBeanWith(cls: any, ...args) {
        let bean = this._beanMap[cls.name] || null;

        if (!bean) {
            bean = this._beanMap[cls.mame] = new cls(...args);
        }

        return bean;
    }

    /**
     * 不可带参数的bean
     * @param cls 
     */
    getBean(cls: any) {
        let bean = this._beanMap[cls.name] || null;

        if (!bean) {
            bean = this._beanMap[cls.mame] = new cls();
        }

        return bean;
    }
  
}

let _beanFactory = new BeanFactory();

export default _beanFactory;